/**
 * Copyright (c) Huawei Technologies Co., Ltd. 1987-2021. All rights reserved.
*/

package com.gitee.fufu669.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/** @author wangfupeng */
/**
 * TODO
*/
public class CacheHtmlUtil {

    /**
     * TODO
    */
    public static final Logger logger = LoggerFactory.getLogger(CacheHtmlUtil.class);

    /**
     * TODO
    */
    public static String getHtmlString(String originalString, String leftString, String rightString, Integer leftArrayIndex, Integer rightArrayIndex){
        // 尝试下面的代码
        try {
            // 切分
            String[] strings = originalString.split(leftString);
            // 切分
            String[] strings1 = strings[leftArrayIndex].split(rightString);
            // 返回
            return strings1[rightArrayIndex];
        // 捕捉异常
        } catch (Exception e) {

            // 返回
            return "";
        }
    }

    /**
     * TODO
    */
    public static String getLastStringSplitHtml(String originalString, String splitString){
        // 尝试下面的代码
        try {
            // 切分
            String[] strings = originalString.split(splitString);
            // 返回
            return strings[strings.length-1];
        // 捕捉异常
        } catch (Exception e) {
            // 返回
            return "";
        }
    }

    /**
     * TODO
    */
    public static String getWordsFromHtml(String html){
        // 返回
        return html.replaceAll("<.*?>", "");
    }

    /**
     * TODO
    */
    public static String getStringWithoutEmpty(String name) {
        // 替换
        name = name.replaceAll(" ", "");
        // 替换
        name = name.replaceAll("    ", "");
        // 替换
        name = name.replaceAll("\n", "");
        // 替换
        name = name.replaceAll("　", "");
        // 返回
        return name;
    }

    /**
     * TODO
    */
    public static String toLowerCaseAtFirstCharacter(String tableName) {
        // 创建
        StringBuilder sb = new StringBuilder(tableName);
        // TODO
        sb.setCharAt(0, Character.toLowerCase(sb.charAt(0)));
        // 返回
        return sb.toString();
    }

    /**
     * TODO
    */
    public static String toUpperCaseAtFirstCharacter(String tableName) {
        // 创建
        StringBuilder sb = new StringBuilder(tableName);
        // TODO
        sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
        // 返回
        return sb.toString();
    }

}
